<template>
  <el-dropdown trigger="click" >
    <i class="el-icon-edit" ></i>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item v-for='(item,index) in events' :key="index" :divided="index >0" @click.native="clickMenu(item)" style="width: 90px;">
      {{item.label}}
    </el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
  export default {
    name: "editDepartment",
    props: {
      events: {
        type: Array,
        default: function() {
          return [
            {
              label: '添加子部门',
              funcName: 'addDepartment'
            },
            {
              label: '编辑部门',
              funcName: 'editDepartment'
            },
            {
              label: '选择成员',
              funcName: 'chooseMember'
            },
            {
              label: '移动部门到...',
              funcName: 'moveDepartment'
            },
            {
              label: '删除部门',
              funcName: 'deleteDepartment'
            }
          ]
        }
      },
      // 注入数据
      data: {
        type: Object
      }
    },
    methods: {
      clickMenu(item) {
        this.$emit(item.funcName, this.data)
      }
    }
  }
</script>

<style scoped>

</style>
